<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>LiquidFun: b2SlabAllocator&lt; T &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">LiquidFun
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classb2_slab_allocator-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">b2SlabAllocator&lt; T &gt; Class Template Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p><code>#include &lt;<a class="el" href="b2_slab_allocator_8h_source.html">b2SlabAllocator.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:aa36e9ae549c8f756cca3a733c87038a2"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_slab_allocator.html#aa36e9ae549c8f756cca3a733c87038a2">b2SlabAllocator</a> (const uint32 itemsPerSlab)</td></tr>
<tr class="separator:aa36e9ae549c8f756cca3a733c87038a2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab59d1761fb13142c034ab83c15888f1a"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab59d1761fb13142c034ab83c15888f1a"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_slab_allocator.html#ab59d1761fb13142c034ab83c15888f1a">~b2SlabAllocator</a> ()</td></tr>
<tr class="memdesc:ab59d1761fb13142c034ab83c15888f1a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Free all allocated slabs. <br/></td></tr>
<tr class="separator:ab59d1761fb13142c034ab83c15888f1a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac017dd277c5e8f6d50933009f7745f39"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_slab_allocator.html#ac017dd277c5e8f6d50933009f7745f39">SetItemsPerSlab</a> (uint32 itemsPerSlab)</td></tr>
<tr class="separator:ac017dd277c5e8f6d50933009f7745f39"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8af772b5ca71b075001c25f68b13cd2b"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8af772b5ca71b075001c25f68b13cd2b"></a>
uint32&#160;</td><td class="memItemRight" valign="bottom"><b>GetItemsPerSlab</b> () const </td></tr>
<tr class="separator:a8af772b5ca71b075001c25f68b13cd2b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0855486c61a5e3345ae4ffce8d7ff20f"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0855486c61a5e3345ae4ffce8d7ff20f"></a>
T *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_slab_allocator.html#a0855486c61a5e3345ae4ffce8d7ff20f">Allocate</a> ()</td></tr>
<tr class="memdesc:a0855486c61a5e3345ae4ffce8d7ff20f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocate a item from the slab. <br/></td></tr>
<tr class="separator:a0855486c61a5e3345ae4ffce8d7ff20f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2a42d4606b0afa41199a18b6affd2cdb"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2a42d4606b0afa41199a18b6affd2cdb"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_slab_allocator.html#a2a42d4606b0afa41199a18b6affd2cdb">Free</a> (T *object)</td></tr>
<tr class="memdesc:a2a42d4606b0afa41199a18b6affd2cdb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Free an item from the slab. <br/></td></tr>
<tr class="separator:a2a42d4606b0afa41199a18b6affd2cdb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a45c7b00371773856ab4bc2b1a5e43b17"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_slab_allocator.html#a45c7b00371773856ab4bc2b1a5e43b17">AllocateSlab</a> ()</td></tr>
<tr class="separator:a45c7b00371773856ab4bc2b1a5e43b17"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab2591405005df4f07c81a1e742687f47"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab2591405005df4f07c81a1e742687f47"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_slab_allocator.html#ab2591405005df4f07c81a1e742687f47">FreeAllSlabs</a> ()</td></tr>
<tr class="memdesc:ab2591405005df4f07c81a1e742687f47"><td class="mdescLeft">&#160;</td><td class="mdescRight">Free all slabs. <br/></td></tr>
<tr class="separator:ab2591405005df4f07c81a1e742687f47"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9d83ad31164f55f8acbd613266f75e56"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_slab_allocator.html#a9d83ad31164f55f8acbd613266f75e56">FreeEmptySlabs</a> ()</td></tr>
<tr class="separator:a9d83ad31164f55f8acbd613266f75e56"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a94571322ed8575513dc4592087e8af19"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a94571322ed8575513dc4592087e8af19"></a>
const <a class="el" href="classb2_typed_free_list.html">b2TypedFreeList</a>&lt; T &gt; &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_slab_allocator.html#a94571322ed8575513dc4592087e8af19">GetFreeList</a> () const </td></tr>
<tr class="memdesc:a94571322ed8575513dc4592087e8af19"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the item allocator freelist. <br/></td></tr>
<tr class="separator:a94571322ed8575513dc4592087e8af19"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;typename T&gt;<br/>
class b2SlabAllocator&lt; T &gt;</h3>

<p>Freelist based allocator for fixed sized items from slabs (memory preallocated from the heap). T should be a class which has a default constructor and implements the member function "b2IntrusiveList* GetListNode()". All objects in a slab are constructed when a slab is created and destructed when a slab is freed. </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="aa36e9ae549c8f756cca3a733c87038a2"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classb2_slab_allocator.html">b2SlabAllocator</a>&lt; T &gt;::<a class="el" href="classb2_slab_allocator.html">b2SlabAllocator</a> </td>
          <td>(</td>
          <td class="paramtype">const uint32&#160;</td>
          <td class="paramname"><em>itemsPerSlab</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Initialize the allocator to allocate itemsPerSlab of type T for each slab that is allocated. </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a45c7b00371773856ab4bc2b1a5e43b17"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classb2_slab_allocator.html">b2SlabAllocator</a>&lt; T &gt;::AllocateSlab </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Allocate a slab, construct instances of T and add them to the free pool. </p>

</div>
</div>
<a class="anchor" id="a9d83ad31164f55f8acbd613266f75e56"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classb2_slab_allocator.html">b2SlabAllocator</a>&lt; T &gt;::FreeEmptySlabs </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Free all empty slabs. This method is slow - O(M^N) - since this class doesn't track the association between each item and slab. </p>

</div>
</div>
<a class="anchor" id="ac017dd277c5e8f6d50933009f7745f39"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classb2_slab_allocator.html">b2SlabAllocator</a>&lt; T &gt;::SetItemsPerSlab </td>
          <td>(</td>
          <td class="paramtype">uint32&#160;</td>
          <td class="paramname"><em>itemsPerSlab</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Set size of the next allocated slab using the number of items per slab. Setting this value to zero disables further slab allocation. </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="b2_slab_allocator_8h_source.html">b2SlabAllocator.h</a></li>
</ul>
</div><!-- contents -->
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-46159502-1', 'auto');
ga('create', 'UA-49880327-7', 'auto', {'name': 'liquidFunTracker'});
ga('send', 'pageview');
ga('liquidFunTracker.send', 'pageview');
</script>
</body>
</html>
